package com.xiangban.yanglaodajie_platform.controller;

import com.xiangban.yanglaodajie_platform.entity.res.ApiResult;
import com.xiangban.yanglaodajie_platform.service.UploadService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/upload")
public class UploadController {
    @Autowired
    private UploadService uploadService;

    @ApiOperation(value = "file",notes = "通用文件上传")
    @PostMapping(value = "/file",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public ApiResult<String> file(@RequestPart(value = "file", required = false) MultipartFile file) {
        return ApiResult.newSuccess(uploadService.file(file));

    }

}
